/* GUI CONVERTED from icptiq01.p (converter v1.76) Wed May 15 00:12:48 2002 */
/* icptiq01.p - STOCK AVAILABILITY INQUIRY                                    */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.8 $                                                           */
/*V8:ConvertMode=Report                                                       */
/* REVISION: 6.0      LAST MODIFIED: 05/10/90   BY: pml                       */
/* REVISION: 6.0      LAST MODIFIED: 08/02/91   BY: bjb *D811*                */
/* REVISION: 7.0      LAST MODIFIED: 07/09/92   BY: pma *F751*                */
/* REVISION: 7.0      LAST MODIFIED: 07/16/92   BY: pma *G133*                */
/* REVISION: 8.6      LAST MODIFIED: 02/17/98   BY: *K1HG* Beena Mol          */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane   */
/* REVISION: 9.1      LAST MODIFIED: 08/13/00   BY: *N0KS* Mark Brown         */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* Revision: 1.7     BY: Jean Miller           DATE: 04/06/02  ECO: *P056*    */
/* $Revision: 1.8 $    BY: A.R. Jayaram          DATE: 05/14/02  ECO: *N1J5*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/* DISPLAY TITLE          */

/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

{mfdtitle.i "2+ "}

define variable part      like pt_part      no-undo.
define variable part_type like pt_part_type no-undo.
define variable prod_line like pt_prod_line no-undo.
define variable site      like pt_site      no-undo.

/* SELECT FORM */

assign
   part = global_part
   site = global_site.


/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   part
   pt_desc1  format "x(20)" no-label
   prod_line
   part_type
   site
with frame a no-underline width 80 attr-space THREE-D /*GUI*/.

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

{wbrp01.i}

/* REPORT BLOCK */

repeat:

   if c-application-mode <> 'web'
   then
      update
         part
         prod_line
         part_type
         site
      with frame a editing:

         if frame-field = "part"
         then do:
            /* FIND NEXT/PREVIOUS RECORD */
            {mfnp.i pt_mstr part pt_part part pt_part pt_part}

            if recno <> ?
            then do:
               part = pt_part.
               display
                  part
                  pt_desc1
               with frame a.
            end. /* IF recno <> ? */
         end. /* IF frame-field = part */
         else if frame-field = "prod_line"
         then do:
            /* FIND NEXT/PREVIOUS RECORD */
            {mfnp.i pt_mstr prod_line pt_prod_line
               prod_line pt_prod_line pt_prod_part}

            if recno <> ?
            then do:
               prod_line = pt_prod_line.
               display
                  prod_line with frame a.
            end. /* IF recno <> ? */
            recno = ?.
         end. /* ELSE IF frame-field = prod_line */
         else do:
            status input.
            readkey.
            apply lastkey.

         end. /* ELSE DO */
      end. /* UPDATE WITH FRAME a EDITING: */

   {wbrp06.i
      &command = update
      &fields = " part prod_line part_type site"
      &frm = "a"}

   if (c-application-mode <> 'web')
   or (c-application-mode = 'web'  and
      (c-web-request begins 'data'))
   then do:

      for first pt_mstr
         fields (pt_desc1 pt_desc2 pt_part pt_part_type pt_prod_line pt_um)
         where pt_part = part
      no-lock:
      end. /* FOR FIRST pt_mstr ... */

      if available pt_mstr
      then
         display
            pt_desc1
         with frame a.
      else
         display
            "" @ pt_desc1
         with frame a.

      hide frame b.
      hide frame c.
      hide frame d.
      hide frame b1.
      hide frame c1.
      hide frame d1.

   end. /* IF c-application-mode <> web .. */

   /* OUTPUT DESTINATION SELECTION */
   {gpselout.i &printType = "terminal"
               &printWidth = 80
               &pagedFlag = " "
               &stream = " "
               &appendToFile = " "
               &streamedOutputToTerminal = " "
               &withBatchOption = "no"
               &displayStatementType = 1
               &withCancelMessage = "yes"
               &pageBottomMargin = 6
               &withEmail = "yes"
               &withWinprint = "yes"
               &defineVariables = "yes"}

   /* FIND AND DISPLAY */
   if part <> ""
   or (prod_line = "" and
       part_type = "" )
   then
      for each pt_mstr
         fields (pt_desc1 pt_desc2 pt_part pt_part_type pt_prod_line pt_um)
         where pt_part >= part
           and (pt_prod_line = prod_line or
                  prod_line = "" )
           and (pt_part_type = part_type or
                  part_type = "" )
           and (if site = ""
                then
                   can-find (first in_mstr
                                where in_part = pt_part)
                else
                   can-find (in_mstr
                                where in_part = pt_part
                                  and in_site = site))
         no-lock
      by pt_part with frame b1 no-underline width 80:

         /* SET EXTERNAL LABELS */
         setFrameLabels(frame b1:handle).

         display
            pt_part
            pt_um
            space(3)
            pt_desc1 no-label
            pt_desc2 no-label WITH STREAM-IO /*GUI*/ .

         for each in_mstr
            fields ( in_part in_qty_all in_qty_avail in_qty_nonet
                     in_qty_oh in_qty_ord in_qty_req in_site )
            where in_part  = pt_part
              and (in_site = site or
                      site = "")
            no-lock
         by in_part by in_site with frame b width 80 no-attr-space:

            /* SET EXTERNAL LABELS */
            setFrameLabels(frame b:handle).

            display
               in_site
               (in_qty_oh + in_qty_nonet) @ in_qty_oh
               in_qty_avail
               in_qty_req
               in_qty_all
               in_qty_ord WITH STREAM-IO /*GUI*/ .

            
/*GUI*/ {mfguirex.i  "false"} /*Replace mfrpexit*/


         end. /* FOR EACH in_mstr ... */

         
/*GUI*/ {mfguirex.i  "false"} /*Replace mfrpexit*/


      end. /* FOR EACH pt_mstr .. */

   else
   if prod_line <> ""
   then
      for each pt_mstr
         fields (pt_desc1 pt_desc2 pt_part pt_part_type pt_prod_line pt_um)
         where pt_prod_line = prod_line
           and (pt_part_type = part_type or
                   part_type = "" )
           and (if site = ""
                then
                   can-find (first in_mstr
                                where in_part = pt_part)
                else
                   can-find (in_mstr
                                where in_part = pt_part
                                  and in_site = site))
         no-lock
      by pt_prod with frame c1 no-underline width 80:

         /* SET EXTERNAL LABELS */
         setFrameLabels(frame c1:handle).

         display
            pt_part
            pt_um
            space(3)
            pt_desc1 no-label
            pt_desc2 no-label WITH STREAM-IO /*GUI*/ .

         for each in_mstr
            fields ( in_part in_qty_all in_qty_avail in_qty_nonet
                     in_qty_oh in_qty_ord in_qty_req in_site )
            where in_part  = pt_part
              and (in_site = site or
                      site = "")
            no-lock
         by in_part by in_site  with frame c width 80 no-attr-space:

            /* SET EXTERNAL LABELS */
            setFrameLabels(frame c:handle).

            display
               in_site
               in_qty_oh
               in_qty_avail
               in_qty_req
               in_qty_all
               in_qty_ord WITH STREAM-IO /*GUI*/ .

            
/*GUI*/ {mfguirex.i  "false"} /*Replace mfrpexit*/


         end. /* FOR EACH in_mstr .. */

         
/*GUI*/ {mfguirex.i  "false"} /*Replace mfrpexit*/


      end.

   else
      if part_type <> ""
      then
         for each pt_mstr   
            fields (pt_desc1 pt_desc2 pt_part pt_part_type pt_prod_line pt_um)
            where pt_part_type = part_type
              and (if site = ""
                   then
                      can-find (first in_mstr
                                   where in_part = pt_part)
                   else
                      can-find (in_mstr
                                   where in_part = pt_part
                                     and in_site = site))
            no-lock
         by pt_part_type by pt_part with frame d1 no-underline width 80:

            /* SET EXTERNAL LABELS */
            setFrameLabels(frame d1:handle).

            display
               pt_part
               pt_um
               space(3)
               pt_desc1 no-label
               pt_desc2 no-label WITH STREAM-IO /*GUI*/ .

            for each in_mstr
               fields ( in_part in_qty_all in_qty_avail in_qty_nonet
                        in_qty_oh in_qty_ord in_qty_req in_site )
               where in_part  = pt_part
                 and (in_site = site
                  or     site = "")
               no-lock
            by in_part by in_site with frame d width 80 no-attr-space:

               /* SET EXTERNAL LABELS */
               setFrameLabels(frame d:handle).

               display
                  in_site
                  in_qty_oh
                  in_qty_avail
                  in_qty_req
                  in_qty_all
                  in_qty_ord WITH STREAM-IO /*GUI*/ .

               
/*GUI*/ {mfguirex.i  "false"} /*Replace mfrpexit*/


            end. /* FOR EACH in_mstr .. */

            
/*GUI*/ {mfguirex.i  "false"} /*Replace mfrpexit*/


         end. /* FOR EACH pt_mstr .. */

      {mfreset.i}
/*GUI*/ {mfgrptrm.i} /*Report-to-Window*/

      {pxmsg.i
         &MSGNUM=8
         &ERRORLEVEL=1}

end. /* REPEAT */

assign
   global_part = part
   global_site = site.

{wbrp04.i &frame-spec = a}
